package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.Subject;
import cn.wolfcode.crm.mapper.SubjectMapper;
import cn.wolfcode.crm.query.SubjectQueryObject;
import cn.wolfcode.crm.service.ISubjectService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SubjectServiceImpl implements ISubjectService {

    @Autowired
    private SubjectMapper mapper;


    public void delete(Long id) {
        mapper.deleteByPrimaryKey(id);
    }

    public void save(Subject entity) {
        mapper.insert(entity);
    }

    public void update(Subject entity) {
        mapper.updateByPrimaryKey(entity);
    }

    public Subject get(Long id) {
        return mapper.selectByPrimaryKey(id);
    }

    public List<?> list() {
        return mapper.selectAll();
    }

    public PageResult query(SubjectQueryObject qo) {


        int total = mapper.queryForCount(qo);
        if (total == 0) {
            return new PageResult();
        }
        List<Subject> list = mapper.queryForList(qo);
        return new PageResult(total,list);
    }


    public void start(Long id) {

    }
}
